#pragma once
#include "../inc_windows_h.hpp"
#include "../wxx_error.hpp"
#include "../string.hpp"
#include "../guid.hpp"

namespace wxx {
namespace com
{
	struct clsid : guid
	{
		explicit clsid() : guid(empty)
		{
		}

		explicit clsid(const ::GUID& g) : guid(g)
		{
		}

		explicit clsid(const olestring& clsid) : guid(from_string(clsid))
		{
		}

		static clsid from_progid(const olestring& progid)
		{
			clsid id;
			
			ensure_success_hr(
				::CLSIDFromProgID(progid.c_str(), &id)
			);

			return id;
		}

	private:
		static ::CLSID from_string(const olestring& str)
		{
			::CLSID id;

			ensure_success_hr(
				::CLSIDFromString(const_cast<::LPOLESTR>(str.c_str()), &id)
			);

			return id;
		}
	};
}}